package com.karrysong.blog_springboot.controller;

import com.karrysong.blog_springboot.service.EmailService;
import com.karrysong.blog_springboot.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

/**
 * @ClassName: EmailController
 * @Author: KarrySong
 * @Date: 2022/8/25 9:46
 * @Description:
 */
@RestController
@RequestMapping("/emails")
public class EmailController {

    @Autowired
    private EmailService emailService;

    @PostMapping("/checkCode/{emailAddress}")
    public Result sendEmailCheckCode(@PathVariable("emailAddress") String emailAddress, HttpSession session){
        return emailService.sendEmailCheckCode(emailAddress);
    }

    @PostMapping("/checkCode/{emailAddress}/{code}")
    public Result checkEmailCheckCode(@PathVariable("emailAddress") String emailAddress, @PathVariable("code") String code, HttpSession session){
        return emailService.checkEmailCheckCode(emailAddress, code);
    }
}
